package com.hl.service;

import com.hl.mapper.UserMapper;
import com.hl.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> listAll() {
        return userMapper.listAll();
    }

    @Override
    @Transactional //代表当前方法启用事务操作
    public int saveAll(List<User> list) {
        int num = 0;
        for (User user: list ) {
            num += userMapper.save(user);
        }
        return num;
    }
}
